Next | Prev | Up | Top | Contents | Index

Using Registry Files

You can make sure that your DSOs don't conflict with each other by using a QuickStart registry file. The registry files contain location information for shared objects. When creating a shared object, you can specify a registry file to ld, and ld ensures that your shared object doesn't conflict with any of the shared objects listed in the registry. A registry file containing the locations of all the shared objects provided with the system is supplied in /usr/lib/so_locations.

You can use two options to ld to specify a registry file: -check_registry and -update_registry. When you invoke ld to build a shared object, with the argument -check_registry file, ld makes sure that the new shared object doesn't conflict with any of the shared objects listed in file. When invoked with -update_registry file, ld checks the registry in the same way, but when it's done, it writes an entry in file for the DSO being built. If file isn't writable, -update_registry acts like -check_registry. If file isn't readable, both -update_registry and -check_registry are ignored.

By exchanging registry files, providers of DSOs can avoid collisions between their shared objects. It's best to start with a copy of /usr/lib/so_locations, so that your shared objects don't conflict with any of the standard DSOs. However, remember that when collisions occur between shared objects, the only effect is slowing program startup.


Registry File Format

Three types of lines in the registry file include:

Comment lines are ignored by ld. Directive lines and shared object specification lines are described below.


Directive Lines

Directive lines specify global parameters that apply to all the DSOs listed in the registry.

$text_align_size=align padding=pad-size
$data_align_size=align padding=pad-size
These two directives specify the alignment and padding requirements for text and data segments, respectively. The current default segment alignment is 64K, which is the minimum permissible. The size value of a segment of a DSO appearing in the registry file is calculated based on the actual section size plus padding, and is aligned to the section align size (either the default or the one specified by the above directive). The align values for text and data as well as the padding values must be aligned to the minimum alignment size (64K). If not, ld generates a warning message and aligns these values to the minimum alignment.

$start_address=addr
This directive specifies where to start looking for addresses to put shared objects. The default start_address is 0x6000000.

$data_after_text={ 1 | 0 }
In this directive, a value of one instructs the linker to place data immediately after the text at specified text and data alignment requirements. A value of zero (the default) allows the linker to place these segments in different portions of the address space.


Shared Object Specification Lines

Shared object specification lines have the following format:

so_name [ :st = {.text | .data | $range} base_addr,padded_size : ] *
where:

so_name

full path name (or trailing component) of a shared object

:st =

literal string indicating the beginning of the segment description

.text, .data

segment types: text or data

$range

range of addresses that can be used

base_addr

address where the segment starts

padded_size

padded size of the segment

:

literal string indicating the end of the segment description
A shared object specification can span several lines by "escaping" the newline character (using "\" as the last character on the line that is being continued). The following is an example of a shared object specification line:

libc.so.1 \
           :st = $range 0x5fc00000, 0x00400000:\
           :st = .text 0x5fe40000, 0x000a0000:\
           :st = .data 0x5fee0000, 0x00030000:
This specification instructs ld to relocate all segments of libc.so.1 in the range 0x5fc00000 to 0x5fc00000+0x0040000, and, if possible, to place the text segment at 0x5fe40000 and the data segment at 0x5fee0000. The text segment should be padded to 0xa0000 bytes and the data segment to 0x3000 bytes. See /usr/lib/so_locations for examples of shared object specifications.

When building a DSO with the -check_registry or -update_registry flag, if an entry corresponding to this DSO exists in the registry file, the linker tries to assign the indicated addresses for text and data. However, if the size of the DSO changes and no longer fits in the specified location, the linker searches for another location that fits. If the $range option is specified, the linker places the DSO only in the specified range of addresses. If there isn't enough room, an error is returned.


Next | Prev | Up | Top | Contents | Index